<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <meta name="description" content="安装RPM包或者安装源码包"/>
    <meta name="keywords"
          content="nginx,freebsd,linux,mysql,shell,apache,centos,redhat,rhel,windows,sql,系统运维,IT运维,开源系统,开源系统运维"/>
    <title> 安装RPM包或者安装源码包 </title>

</head>
<body bgcolor="#FFFFFF" text="#000000">
<div id="menu">
    <ul>
		<span style="FONT-SIZE: 10.5pt">

			<li><a href="index.htm" hidefocus="true" id="mn_list">linux入门教程</a></li>

		</span>
    </ul>
</div>
<p style="text-align: center;"><span style="font-family:'宋体';font-size:15pt;"><b>第十一章</b></span><span
        style="font-family:'Calibri';font-size:15pt;"><b>	</b></span><span
        style="font-family:'宋体';font-size:15pt;"><b>安装</b></span><span style="font-family:'Calibri';font-size:15pt;"><b>RPM</b></span><span
        style="font-family:'宋体';font-size:15pt;"><b>包或者安装源码包</b></span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">在</span><span
        style="font-family:'Calibri';font-size:10.5pt;">windows</span><span style="font-family:'宋体';font-size:10.5pt;">下安装一个软件很轻松，只要双击</span><span
        style="font-family:'Calibri';font-size:10.5pt;">.exe</span><span style="font-family:'宋体';font-size:10.5pt;">的文件，安装提示连续</span><span
        style="font-family:'Calibri';font-size:10.5pt;">“</span><span
        style="font-family:'宋体';font-size:10.5pt;">下一步</span><span
        style="font-family:'Calibri';font-size:10.5pt;">”</span><span
        style="font-family:'宋体';font-size:10.5pt;">即可，然而</span><span style="font-family:'Calibri';font-size:10.5pt;">linux</span><span
        style="font-family:'宋体';font-size:10.5pt;">系统下安装一个软件似乎并不那么轻松了，因为我们不是在图形界面下</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">所以你要学会如何在</span><span
        style="font-family:'Calibri';font-size:10.5pt;">linux</span><span style="font-family:'宋体';font-size:10.5pt;">下安装一个软件</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>


<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">在前面的内容中多次提到的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">yum</span><span
        style="font-family:'宋体';font-size:10.5pt;">，这个</span><span
        style="font-family:'Calibri';font-size:10.5pt;">yum</span><span
        style="font-family:'宋体';font-size:10.5pt;">是</span><span
        style="font-family:'Calibri';font-size:10.5pt;">Redhat</span><span style="font-family:'宋体';font-size:10.5pt;">所特有的安装</span><span
        style="font-family:'Calibri';font-size:10.5pt;">RPM</span><span style="font-family:'宋体';font-size:10.5pt;">程序包的工具，使用起来相当方便</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">因为使用</span><span
        style="font-family:'Calibri';font-size:10.5pt;">RPM</span><span style="font-family:'宋体';font-size:10.5pt;">安装某一个程序包有可能会因为该程序包依赖另一个程序包而无法安装</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">而使用</span><span
        style="font-family:'Calibri';font-size:10.5pt;">yum</span><span style="font-family:'宋体';font-size:10.5pt;">工具就可以连同依赖的程序包一起安装</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">当然</span><span
        style="font-family:'Calibri';font-size:10.5pt;">CentOS</span><span style="font-family:'宋体';font-size:10.5pt;">同样可以使用</span><span
        style="font-family:'Calibri';font-size:10.5pt;">yum</span><span style="font-family:'宋体';font-size:10.5pt;">工具，而且在</span><span
        style="font-family:'Calibri';font-size:10.5pt;">CentOS</span><span style="font-family:'宋体';font-size:10.5pt;">中你可以免费使用</span><span
        style="font-family:'Calibri';font-size:10.5pt;">yum</span><span
        style="font-family:'宋体';font-size:10.5pt;">，但</span><span
        style="font-family:'Calibri';font-size:10.5pt;">Redhat</span><span style="font-family:'宋体';font-size:10.5pt;">中只有当你付费后才能使用</span><span
        style="font-family:'Calibri';font-size:10.5pt;">yum</span><span style="font-family:'宋体';font-size:10.5pt;">，默认是无法使用</span><span
        style="font-family:'Calibri';font-size:10.5pt;">yum</span><span
        style="font-family:'宋体';font-size:10.5pt;">的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">在介绍</span><span
        style="font-family:'Calibri';font-size:10.5pt;">yum</span><span style="font-family:'宋体';font-size:10.5pt;">之前先说一说</span><span
        style="font-family:'Calibri';font-size:10.5pt;">RPM</span><span
        style="font-family:'宋体';font-size:10.5pt;">相关的东西</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">【</span><span
        style="font-family:'Calibri';font-size:10.5pt;"><b>RPM</b></span><span
        style="font-family:'宋体';font-size:10.5pt;"><b>工具</b></span><span
        style="font-family:'Calibri';font-size:10.5pt;">】</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	RPM</span><span
        style="font-family:'宋体';font-size:10.5pt;">是</span><span style="font-family:'Calibri';font-size:10.5pt;">”Redhat  Package  Manager”</span><span
        style="font-family:'宋体';font-size:10.5pt;">的缩写，根据名字也能猜到这是</span><span
        style="font-family:'Calibri';font-size:10.5pt;">Redhat</span><span style="font-family:'宋体';font-size:10.5pt;">公司开发出来的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。RPM </span><span style="font-family:'宋体';font-size:10.5pt;">是以一种数据库记录的方式来将你所需要的套件安装到你的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">Linux </span><span style="font-family:'宋体';font-size:10.5pt;">主机的一套管理程序</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">也就是说，你的</span><span style="font-family:'Calibri';font-size:10.5pt;">linux</span><span
        style="font-family:'宋体';font-size:10.5pt;">系统中存在着一个关于</span><span
        style="font-family:'Calibri';font-size:10.5pt;">RPM</span><span style="font-family:'宋体';font-size:10.5pt;">的数据库，它记录了安装的包以及包与包之间依赖相关性</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。RPM</span><span style="font-family:'宋体';font-size:10.5pt;">包是预先在</span><span
        style="font-family:'Calibri';font-size:10.5pt;">linux</span><span style="font-family:'宋体';font-size:10.5pt;">机器上编译好并打包好的文件，安装起来非常快捷</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">但是也有一些缺点，比如安装的环境必须与编译时的环境一致或者相当；包与包之间存在着相互依赖的情况；卸载包时需要先把依赖的包卸载掉，如果依赖的包是系统所必须的，那就不能卸载这个包，否则会造成系统崩溃</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span
        style="font-family:'宋体';font-size:10.5pt;">如果你的光驱中还有系统安装盘的话，你可以通过</span><span
        style="font-family:'Calibri';font-size:10.5pt;">”mount /dev/cdrom /mnt”</span><span
        style="font-family:'宋体';font-size:10.5pt;">命令把光驱挂载到</span><span style="font-family:'Calibri';font-size:10.5pt;">/mnt</span><span
        style="font-family:'宋体';font-size:10.5pt;">目录下，那么你会在</span><span
        style="font-family:'Calibri';font-size:10.5pt;">/mnt/CentOS</span><span
        style="font-family:'宋体';font-size:10.5pt;">目录下看到很多</span><span style="font-family:'Calibri';font-size:10.5pt;">.rpm</span><span
        style="font-family:'宋体';font-size:10.5pt;">的文件，这就是</span><span style="font-family:'Calibri';font-size:10.5pt;">RPM</span><span
        style="font-family:'宋体';font-size:10.5pt;">包了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="11_1.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">每一个</span><span
        style="font-family:'Calibri';font-size:10.5pt;">rpm</span><span style="font-family:'宋体';font-size:10.5pt;">包的名称都由</span><span
        style="font-family:'Calibri';font-size:10.5pt;">”-“</span><span
        style="font-family:'宋体';font-size:10.5pt;">和</span><span
        style="font-family:'Calibri';font-size:10.5pt;">”.”</span><span style="font-family:'宋体';font-size:10.5pt;">分成了若干部分</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">就拿</span><span style="font-family:'Calibri';font-size:10.5pt;"> a2ps-4.13b-57.2.el5.i386.rpm </span><span
        style="font-family:'宋体';font-size:10.5pt;">这个包来解释一下，</span><span
        style="font-family:'Calibri';font-size:10.5pt; color:#FF0000;">a2ps </span><span
        style="font-family:'宋体';font-size:10.5pt; color:#FF0000;">为包名；</span><span
        style="font-family:'Calibri';font-size:10.5pt; color:#FF0000;">4.13b</span><span
        style="font-family:'宋体';font-size:10.5pt; color:#FF0000;">则为版本信息；</span><span
        style="font-family:'Calibri';font-size:10.5pt; color:#FF0000;">57.2.el5</span><span
        style="font-family:'宋体';font-size:10.5pt; color:#FF0000;">为发布版本号；</span><span
        style="font-family:'Calibri';font-size:10.5pt; color:#FF0000;">i386</span><span
        style="font-family:'宋体';font-size:10.5pt; color:#FF0000;">为运行平台</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">其中运行平台常见的有</span><span
        style="font-family:'Calibri';font-size:10.5pt;">i386, i586, i686, x86_64 </span><span
        style="font-family:'宋体';font-size:10.5pt;">，需要你注意的是</span><span style="font-family:'Calibri';font-size:10.5pt;">cpu</span><span
        style="font-family:'宋体';font-size:10.5pt;">目前是分</span><span
        style="font-family:'Calibri';font-size:10.5pt;">32</span><span
        style="font-family:'宋体';font-size:10.5pt;">位和</span><span
        style="font-family:'Calibri';font-size:10.5pt;">64</span><span
        style="font-family:'宋体';font-size:10.5pt;">位的，</span><span style="font-family:'Calibri';font-size:10.5pt;">i386,i586</span><span
        style="font-family:'宋体';font-size:10.5pt;">和</span><span
        style="font-family:'Calibri';font-size:10.5pt;">i686</span><span
        style="font-family:'宋体';font-size:10.5pt;">都为</span><span
        style="font-family:'Calibri';font-size:10.5pt;">32</span><span
        style="font-family:'宋体';font-size:10.5pt;">位平台，</span><span style="font-family:'Calibri';font-size:10.5pt;">x86_64</span><span
        style="font-family:'宋体';font-size:10.5pt;">则代表为</span><span
        style="font-family:'Calibri';font-size:10.5pt;">64</span><span
        style="font-family:'宋体';font-size:10.5pt;">位的平台</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">另外有些</span><span
        style="font-family:'Calibri';font-size:10.5pt;">rpm</span><span style="font-family:'宋体';font-size:10.5pt;">包并没有写具体的平台而是</span><span
        style="font-family:'Calibri';font-size:10.5pt;">noarch</span><span style="font-family:'宋体';font-size:10.5pt;">，这代表这个</span><span
        style="font-family:'Calibri';font-size:10.5pt;">rpm</span><span style="font-family:'宋体';font-size:10.5pt;">包没有硬件平台限制</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">例如</span><span style="font-family:'Calibri';font-size:10.5pt;"> alacarte-0.10.0-1.fc6.noarch.rpm 。</span><span
        style="font-family:'宋体';font-size:10.5pt;">下面介绍一下</span><span style="font-family:'Calibri';font-size:10.5pt;">rpm</span><span
        style="font-family:'宋体';font-size:10.5pt;">常用的命令</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">1</span><span
        style="font-family:'宋体';font-size:10.5pt;">）安装一个</span><span
        style="font-family:'Calibri';font-size:10.5pt;">rpm</span><span
        style="font-family:'宋体';font-size:10.5pt;">包</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="11_7.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">-i </span><span
        style="font-family:'宋体';font-size:10.5pt;">：安装的意思</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">-v </span><span
        style="font-family:'宋体';font-size:10.5pt;">：可视化</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">-h </span><span
        style="font-family:'宋体';font-size:10.5pt;">：显示安装进度</span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">另外在安装一个</span><span
        style="font-family:'Calibri';font-size:10.5pt;">rpm</span><span style="font-family:'宋体';font-size:10.5pt;">包时常用的附带参数有：</span>
</p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">--force </span><span
        style="font-family:'宋体';font-size:10.5pt;">强制安装，即使覆盖属于其他包的文件也要安装</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">--nodeps </span><span
        style="font-family:'宋体';font-size:10.5pt;">当要安装的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">rpm</span><span style="font-family:'宋体';font-size:10.5pt;">包依赖其他包时，即使其他包没有安装，也要安装这个包</span>
</p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">2</span><span
        style="font-family:'宋体';font-size:10.5pt;">）升级一个</span><span
        style="font-family:'Calibri';font-size:10.5pt;">rpm</span><span
        style="font-family:'宋体';font-size:10.5pt;">包</span></p>
<p style="text-align: justify;"><span
        style="font-family:'Calibri';font-size:10.5pt;">rpm -Uvh  filename    -U </span><span
        style="font-family:'宋体';font-size:10.5pt;">：即升级的意思</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">3</span><span
        style="font-family:'宋体';font-size:10.5pt;">）卸载一个</span><span
        style="font-family:'Calibri';font-size:10.5pt;">rpm</span><span
        style="font-family:'宋体';font-size:10.5pt;">包</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">rpm -e  filename  </span><span
        style="font-family:'宋体';font-size:10.5pt;">这里的</span><span style="font-family:'Calibri';font-size:10.5pt;">filename</span><span
        style="font-family:'宋体';font-size:10.5pt;">是通过</span><span
        style="font-family:'Calibri';font-size:10.5pt;">rpm</span><span style="font-family:'宋体';font-size:10.5pt;">的查询功能所查询到的，稍后会作介绍</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="11_8.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">卸载时后边跟的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">filename</span><span style="font-family:'宋体';font-size:10.5pt;">和安装时的是有区别的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">上面命令提到的</span><span style="font-family:'Calibri';font-size:10.5pt;"> “|”</span><span
        style="font-family:'宋体';font-size:10.5pt;">在</span><span
        style="font-family:'Calibri';font-size:10.5pt;">linux</span><span style="font-family:'宋体';font-size:10.5pt;">系统中用的非常多也非常有用，它是一个管道符，用来把前面运行的结果传递给后面的命令</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">以后会做详细介绍，而后出现的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">grep</span><span style="font-family:'宋体';font-size:10.5pt;">命令则是用来过滤某个关键词的工具，在后续章节中会做详细介绍</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">4</span><span
        style="font-family:'宋体';font-size:10.5pt;">）查询一个包是否安装</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">rpm  -q  rpm</span><span
        style="font-family:'宋体';font-size:10.5pt;">包名（这里的包名，是不带有平台信息以及后缀名的）</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="11_9.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">如果加上了平台信息以及后缀名反而不能查出来</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">你还可以查询当前系统中所安装的所有</span><span
        style="font-family:'Calibri';font-size:10.5pt;">rpm</span><span
        style="font-family:'宋体';font-size:10.5pt;">包</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="11_10.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">因为太多，所以笔者列出前十个</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">5</span><span
        style="font-family:'宋体';font-size:10.5pt;">）得到一个</span><span
        style="font-family:'Calibri';font-size:10.5pt;">rpm</span><span style="font-family:'宋体';font-size:10.5pt;">包的相关信息</span>
</p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">rpm  -qi  </span><span
        style="font-family:'宋体';font-size:10.5pt;">包名</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> </span><span style="font-family:'宋体';font-size:10.5pt;">（同样不需要加平台信息与后缀名）</span>
</p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="11_11.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">6</span><span
        style="font-family:'宋体';font-size:10.5pt;">）列出一个</span><span
        style="font-family:'Calibri';font-size:10.5pt;">rpm</span><span style="font-family:'宋体';font-size:10.5pt;">包安装的文件</span>
</p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">rpm -ql  </span><span
        style="font-family:'宋体';font-size:10.5pt;">包名</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="11_21.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">通过上面的命令可以看出</span><span
        style="font-family:'Calibri';font-size:10.5pt;">vim</span><span
        style="font-family:'宋体';font-size:10.5pt;">是通过安装</span><span style="font-family:'Calibri';font-size:10.5pt;">vim-enhanced-7.0.109-6.el5</span><span
        style="font-family:'宋体';font-size:10.5pt;">这个</span><span
        style="font-family:'Calibri';font-size:10.5pt;">rpm</span><span
        style="font-family:'宋体';font-size:10.5pt;">包得来的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">那么反过来如何通过一个文件去查找是由安装哪个</span><span
        style="font-family:'Calibri';font-size:10.5pt;">rpm</span><span
        style="font-family:'宋体';font-size:10.5pt;">包得来的？</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">7</span><span
        style="font-family:'宋体';font-size:10.5pt;">）列出某一个文件属于哪个</span><span
        style="font-family:'Calibri';font-size:10.5pt;">rpm</span><span
        style="font-family:'宋体';font-size:10.5pt;">包</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">rpm  -qf  </span><span
        style="font-family:'宋体';font-size:10.5pt;">文件的绝对路径</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="11_22.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">前面讲过如何查找一个文件（可执行命令）的绝对路径</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="11_23.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">所以你也可以把这两条命令连起来写</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="11_24.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">看到了吗，</span><span
        style="font-family:'Calibri';font-size:10.5pt;">which vim </span><span
        style="font-family:'宋体';font-size:10.5pt;">这条命令是由两个反引号引起来的，这代表引用反引号里面的命令所产生的结果</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">关于</span><span
        style="font-family:'Calibri';font-size:10.5pt;">rpm</span><span style="font-family:'宋体';font-size:10.5pt;">工具的使用还有很多内容，笔者就不一一列举了，只要你掌握上面这些内容，完全够你平时工作用的了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">【</span><span
        style="font-family:'Calibri';font-size:10.5pt;"><b>yum</b></span><span
        style="font-family:'宋体';font-size:10.5pt;"><b>工具</b></span><span
        style="font-family:'Calibri';font-size:10.5pt;">】</span></p>
<p style="text-align: justify;text-indent: 21pt;"><span style="font-family:'宋体';font-size:10.5pt;">介绍完</span><span
        style="font-family:'Calibri';font-size:10.5pt;">rpm</span><span style="font-family:'宋体';font-size:10.5pt;">工具后，还需要你掌握最常用的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">yum</span><span style="font-family:'宋体';font-size:10.5pt;">工具，这个工具比</span><span
        style="font-family:'Calibri';font-size:10.5pt;">rpm</span><span style="font-family:'宋体';font-size:10.5pt;">工具好用多了，当然前提是你使用的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">linux</span><span style="font-family:'宋体';font-size:10.5pt;">系统是支持</span><span
        style="font-family:'Calibri';font-size:10.5pt;">yum</span><span
        style="font-family:'宋体';font-size:10.5pt;">的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。yum</span><span style="font-family:'宋体';font-size:10.5pt;">最大的优势在于可以联网去下载所需要的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">rpm</span><span style="font-family:'宋体';font-size:10.5pt;">包，然后自动安装，在这个工程中如果要安装的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">rpm</span><span style="font-family:'宋体';font-size:10.5pt;">包有依赖关系，</span><span
        style="font-family:'Calibri';font-size:10.5pt;">yum</span><span style="font-family:'宋体';font-size:10.5pt;">会帮你解决掉这些依赖关系依次安装所有</span><span
        style="font-family:'Calibri';font-size:10.5pt;">rpm</span><span
        style="font-family:'宋体';font-size:10.5pt;">包</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">下面笔者介绍常用的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">yum </span><span
        style="font-family:'宋体';font-size:10.5pt;">命令</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;text-indent: 21pt;"><span style="font-family:'Calibri';font-size:10.5pt;">1</span><span
        style="font-family:'宋体';font-size:10.5pt;">）</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> </span><span
        style="font-family:'宋体';font-size:10.5pt;">列出所有可用的</span><span style="font-family:'Calibri';font-size:10.5pt;">rpm</span><span
        style="font-family:'宋体';font-size:10.5pt;">包</span><span style="font-family:'Calibri';font-size:10.5pt;">  “yum list “</span>
</p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="11_25.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">限于篇幅，笔者只列举出来前</span><span
        style="font-family:'Calibri';font-size:10.5pt;">7</span><span
        style="font-family:'宋体';font-size:10.5pt;">个包信息</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">从上例中可以看到有</span><span
        style="font-family:'Calibri';font-size:10.5pt;">”mirrors.163.com”</span><span
        style="font-family:'宋体';font-size:10.5pt;">信息出现，这是在告诉用户，它是从</span><span
        style="font-family:'Calibri';font-size:10.5pt;">mirrors.163.com</span><span
        style="font-family:'宋体';font-size:10.5pt;">这里下载到的</span><span style="font-family:'Calibri';font-size:10.5pt;">rpm</span><span
        style="font-family:'宋体';font-size:10.5pt;">包资源</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">如果你使用的是</span><span style="font-family:'Calibri';font-size:10.5pt;">CentOS</span><span
        style="font-family:'宋体';font-size:10.5pt;">则你可以从</span><span style="font-family:'Calibri';font-size:10.5pt;">/etc/yum.repos.d/CentOS-Base.repo</span><span
        style="font-family:'宋体';font-size:10.5pt;">这个文件下看到相关的配置信息</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">从上面的例子中你还可以看到最左侧是</span><span
        style="font-family:'Calibri';font-size:10.5pt;">rpm</span><span style="font-family:'宋体';font-size:10.5pt;">包名字，中间是版本信息，最右侧是安装信息，如果安装了就显示</span><span
        style="font-family:'Calibri';font-size:10.5pt;">installed</span><span
        style="font-family:'宋体';font-size:10.5pt;">，未安装则显示</span><span style="font-family:'Calibri';font-size:10.5pt;">base</span><span
        style="font-family:'宋体';font-size:10.5pt;">或者</span><span
        style="font-family:'Calibri';font-size:10.5pt;">extras</span><span style="font-family:'宋体';font-size:10.5pt;">，如果是该</span><span
        style="font-family:'Calibri';font-size:10.5pt;">rpm</span><span style="font-family:'宋体';font-size:10.5pt;">包已安装但需要升级则显示</span><span
        style="font-family:'Calibri';font-size:10.5pt;">updates。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">	2</span><span
        style="font-family:'宋体';font-size:10.5pt;">）搜索一个</span><span
        style="font-family:'Calibri';font-size:10.5pt;">rpm</span><span
        style="font-family:'宋体';font-size:10.5pt;">包</span><span style="font-family:'Calibri';font-size:10.5pt;">  “yum search  [</span><span
        style="font-family:'宋体';font-size:10.5pt;">相关关键词</span><span
        style="font-family:'Calibri';font-size:10.5pt;">]”</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="11_26.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">除了这样搜索外，笔者常用的是利用</span><span
        style="font-family:'Calibri';font-size:10.5pt;">grep</span><span
        style="font-family:'宋体';font-size:10.5pt;">来过滤</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="11_27.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">相信你也会喜欢用后者吧，这样看起来简明的多</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;text-indent: 21pt;"><span style="font-family:'Calibri';font-size:10.5pt;">3</span><span
        style="font-family:'宋体';font-size:10.5pt;">）安装一个</span><span
        style="font-family:'Calibri';font-size:10.5pt;">rpm</span><span
        style="font-family:'宋体';font-size:10.5pt;">包</span><span style="font-family:'Calibri';font-size:10.5pt;"> “yum install  [-y]  [rpm</span><span
        style="font-family:'宋体';font-size:10.5pt;">包名</span><span
        style="font-family:'Calibri';font-size:10.5pt;">]”</span></p>
<p><span style="font-family:'宋体';font-size:10.5pt;">如果不加</span><span
        style="font-family:'Calibri';font-size:10.5pt;">-y</span><span style="font-family:'宋体';font-size:10.5pt;">选项，则会以与用户交互的方式安装，首先是列出需要安装的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">rpm</span><span style="font-family:'宋体';font-size:10.5pt;">包信息，然后会问用户是否需要安装，输入</span><span
        style="font-family:'Calibri';font-size:10.5pt;">y</span><span
        style="font-family:'宋体';font-size:10.5pt;">则安装，输入</span><span
        style="font-family:'Calibri';font-size:10.5pt;">n</span><span
        style="font-family:'宋体';font-size:10.5pt;">则不安装</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">而笔者嫌这样太麻烦，所以直接加上</span><span
        style="font-family:'Calibri';font-size:10.5pt;">-y</span><span style="font-family:'宋体';font-size:10.5pt;">选项，这样就省略掉了问用户是否安装的那一步</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。<img src="11_28.png"></span></p>
<p><span style="font-family:'Calibri';font-size:10.5pt;">	4</span><span style="font-family:'宋体';font-size:10.5pt;">）卸载一个</span><span
        style="font-family:'Calibri';font-size:10.5pt;">rpm</span><span
        style="font-family:'宋体';font-size:10.5pt;">包</span><span style="font-family:'Calibri';font-size:10.5pt;"> “yum remove  [-y]  [rpm</span><span
        style="font-family:'宋体';font-size:10.5pt;">包名</span><span
        style="font-family:'Calibri';font-size:10.5pt;">]”</span></p>
<p><span style="font-family:'Calibri';font-size:10.5pt;"><img src="11_29.png"></span></p>
<p><span style="font-family:'宋体';font-size:10.5pt;">卸载和安装一样，你也可以直接加上</span><span
        style="font-family:'Calibri';font-size:10.5pt;">-y</span><span style="font-family:'宋体';font-size:10.5pt;">选项来省略掉和用户交互的步骤</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">在这里笔者要提醒你一下，卸载某个</span><span
        style="font-family:'Calibri';font-size:10.5pt;">rpm</span><span style="font-family:'宋体';font-size:10.5pt;">包一定要看清楚了，不要连其他重要的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">rpm</span><span style="font-family:'宋体';font-size:10.5pt;">包一起卸载了，以免影响正常的业务</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-indent: 21pt;"><span style="font-family:'Calibri';font-size:10.5pt;">4</span><span
        style="font-family:'宋体';font-size:10.5pt;">）升级一个</span><span
        style="font-family:'Calibri';font-size:10.5pt;">rpm</span><span
        style="font-family:'宋体';font-size:10.5pt;">包</span><span style="font-family:'Calibri';font-size:10.5pt;"> “yum  update [-y]  [rpm</span><span
        style="font-family:'宋体';font-size:10.5pt;">包</span><span
        style="font-family:'Calibri';font-size:10.5pt;">]”</span></p>
<p><span style="font-family:'Calibri';font-size:10.5pt;"><img src="11_44.png"></span></p>
<p><span style="font-family:'宋体';font-size:10.5pt;">以上介绍了如何使用</span><span
        style="font-family:'Calibri';font-size:10.5pt;">yum</span><span
        style="font-family:'宋体';font-size:10.5pt;">搜索</span><span
        style="font-family:'Calibri';font-size:10.5pt;">、</span><span
        style="font-family:'宋体';font-size:10.5pt;">安装</span><span
        style="font-family:'Calibri';font-size:10.5pt;">、</span><span style="font-family:'宋体';font-size:10.5pt;">卸载以及升级一个</span><span
        style="font-family:'Calibri';font-size:10.5pt;">rpm</span><span style="font-family:'宋体';font-size:10.5pt;">包，如果你掌握了这些那么你就已经可以解决日常工作中遇到的与</span><span
        style="font-family:'Calibri';font-size:10.5pt;">rpm</span><span style="font-family:'宋体';font-size:10.5pt;">包相关问题了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">当然</span><span
        style="font-family:'Calibri';font-size:10.5pt;">yum</span><span style="font-family:'宋体';font-size:10.5pt;">工具还有好多其他好用的命令，笔者不在列举出来，如果你感兴趣就去</span><span
        style="font-family:'Calibri';font-size:10.5pt;">man</span><span
        style="font-family:'宋体';font-size:10.5pt;">一下吧</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">除此之外，笔者还会教你一些关于</span><span
        style="font-family:'Calibri';font-size:10.5pt;">yum</span><span
        style="font-family:'宋体';font-size:10.5pt;">的小应用</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p><span style="font-family:'Calibri';font-size:10.5pt;"><b>1  </b></span><span
        style="font-family:'宋体';font-size:10.5pt;"><b>使用本地的光盘来制作一个</b></span><span
        style="font-family:'Calibri';font-size:10.5pt;"><b>yum</b></span><span
        style="font-family:'宋体';font-size:10.5pt;"><b>源</b></span></p>
<p><span style="font-family:'宋体';font-size:10.5pt;">有时候你的</span><span style="font-family:'Calibri';font-size:10.5pt;">linux</span><span
        style="font-family:'宋体';font-size:10.5pt;">系统不能联网，当然就不能很便捷的使用联网的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">yum</span><span style="font-family:'宋体';font-size:10.5pt;">源了，这时候就需要你自己会利用</span><span
        style="font-family:'Calibri';font-size:10.5pt;">linux</span><span style="font-family:'宋体';font-size:10.5pt;">系统光盘制作一个</span><span
        style="font-family:'Calibri';font-size:10.5pt;">yum</span><span
        style="font-family:'宋体';font-size:10.5pt;">源</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">具体步骤如下：</span></p>
<p><span style="font-family:'Calibri';font-size:10.5pt;">a.</span><span
        style="font-family:'宋体';font-size:10.5pt;">挂载光盘</span></p>
<p><span
        style="font-family:'Calibri';font-size:10.5pt;">[root@fortest Server]# mount -t iso9660 -o loop /dev/cdrom /mnt</span>
</p>
<p><span style="font-family:'Calibri';font-size:10.5pt;">b.</span><span
        style="font-family:'宋体';font-size:10.5pt;">删除</span><span style="font-family:'Calibri';font-size:10.5pt;">/etc/yum.repos.d</span><span
        style="font-family:'宋体';font-size:10.5pt;">目录所有的</span><span style="font-family:'Calibri';font-size:10.5pt;">repo</span><span
        style="font-family:'宋体';font-size:10.5pt;">文件</span></p>
<p><span style="font-family:'Calibri';font-size:10.5pt;">[root@fortest Server]# rm -rf /etc/yum.repos.d/*</span></p>
<p><span style="font-family:'Calibri';font-size:10.5pt;">c.</span><span
        style="font-family:'宋体';font-size:10.5pt;">创建新文件</span><span style="font-family:'Calibri';font-size:10.5pt;">dvd.repo</span>
</p>
<p><span style="font-family:'Calibri';font-size:10.5pt;">[root@fortest Server]# vim /etc/yum.repos.d/dvd.repo</span></p>
<p><span style="font-family:'宋体';font-size:10.5pt;">加入以下内容：</span></p>
<p><span style="font-family:'Calibri';font-size:10.5pt;">[dvd]</span></p>
<p><span style="font-family:'Calibri';font-size:10.5pt;">name=install dvd</span></p>
<p><span style="font-family:'Calibri';font-size:10.5pt;">baseurl=file:///mnt</span></p>
<p><span style="font-family:'Calibri';font-size:10.5pt;">enabled=1</span></p>
<p><span style="font-family:'Calibri';font-size:10.5pt;">gpgcheck=0</span></p>
<p><span style="font-family:'Calibri';font-size:10.5pt;">d.</span><span
        style="font-family:'宋体';font-size:10.5pt;">刷新</span><span
        style="font-family:'Calibri';font-size:10.5pt;">repos,</span><span style="font-family:'宋体';font-size:10.5pt;">生成缓存</span>
</p>
<p><span style="font-family:'Calibri';font-size:10.5pt;">[root@fortest Server]#yum makecache</span></p>
<p><span style="font-family:'宋体';font-size:10.5pt;">然后就可以使用</span><span style="font-family:'Calibri';font-size:10.5pt;">yum</span><span
        style="font-family:'宋体';font-size:10.5pt;">命令安装你所需要的软件包了</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> </span></p>
<p><span style="font-family:'Calibri';font-size:10.5pt;"><b>2 </b></span><span
        style="font-family:'宋体';font-size:10.5pt;"><b>利用</b></span><span
        style="font-family:'Calibri';font-size:10.5pt;"><b>yum</b></span><span
        style="font-family:'宋体';font-size:10.5pt;"><b>工具下载一个</b></span><span
        style="font-family:'Calibri';font-size:10.5pt;"><b>rpm</b></span><span
        style="font-family:'宋体';font-size:10.5pt;"><b>包</b></span></p>
<p><span style="font-family:'宋体';font-size:10.5pt;">有时，我们需要下载一个</span><span
        style="font-family:'Calibri';font-size:10.5pt;">rpm</span><span style="font-family:'宋体';font-size:10.5pt;">包，只是下载下来，拷贝给其他机器使用，前面也介绍过</span><span
        style="font-family:'Calibri';font-size:10.5pt;">yum</span><span
        style="font-family:'宋体';font-size:10.5pt;">安装</span><span
        style="font-family:'Calibri';font-size:10.5pt;">rpm</span><span style="font-family:'宋体';font-size:10.5pt;">包的时候，首先得下载这个</span><span
        style="font-family:'Calibri';font-size:10.5pt;">rpm</span><span style="font-family:'宋体';font-size:10.5pt;">包然后再去安装，所以使用</span><span
        style="font-family:'Calibri';font-size:10.5pt;">yum</span><span style="font-family:'宋体';font-size:10.5pt;">完全可以做到只下载而不安装</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p><span style="font-family:'Calibri';font-size:10.5pt;">a. </span><span style="font-family:'宋体';font-size:10.5pt;">首选要安装</span><span
        style="font-family:'Calibri';font-size:10.5pt;"> yum-downloadonly </span></p>
<p><span style="font-family:'Calibri';font-size:10.5pt;"># yum install -y yum-downloadonly.noarch</span></p>
<p><span style="font-family:'Calibri';font-size:10.5pt;">b. </span><span
        style="font-family:'宋体';font-size:10.5pt;">下载一个</span><span
        style="font-family:'Calibri';font-size:10.5pt;">rpm</span><span
        style="font-family:'宋体';font-size:10.5pt;">包而不安装</span></p>
<p><span style="font-family:'Calibri';font-size:10.5pt;"># yum install test.rpm -y --downloadonly   //</span><span
        style="font-family:'宋体';font-size:10.5pt;">这样虽然下载了，但是并没有保存到我们想要的目录下，那么如何指定目录呢？</span></p>
<p><span style="font-family:'Calibri';font-size:10.5pt;">c. </span><span style="font-family:'宋体';font-size:10.5pt;">下载到指定目录</span>
</p>
<p><span style="font-family:'Calibri';font-size:10.5pt;"># yum install test.rpm -y --downloadonly   --downloaddir=/usr/local/src </span>
</p>
<p><span style="font-family:'Calibri';font-size:10.5pt;"><img src="11_45.png"></span></p>
<p><span style="font-family:'Calibri';font-size:10.5pt;">【</span><span style="font-family:'宋体';font-size:10.5pt;"><b>安装源码包</b></span><span
        style="font-family:'Calibri';font-size:10.5pt;">】</span></p>
<p><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span style="font-family:'宋体';font-size:10.5pt;">其实，在</span><span
        style="font-family:'Calibri';font-size:10.5pt;">linux</span><span style="font-family:'宋体';font-size:10.5pt;">下面安装一个源码包是最常用的，笔者在日常的管理工作中，大部分软件都是通过源码安装的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">安装一个源码包，是需要我们自己把源代码编译成二进制的可执行文件</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">如果你读得懂这些源代码，那么你就可以去修改这些源代码自定义功能，然后再去编译成你想要的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">使用源码包的好处除了可以自定义修改源代码外还可以定制相关的功能，因为源码包在编译的时候是可以附加额外的选项的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p><span style="font-family:'Calibri';font-size:10.5pt;">	</span><span style="font-family:'宋体';font-size:10.5pt;">源码包的编译用到了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">linux</span><span style="font-family:'宋体';font-size:10.5pt;">系统里的编译器，常见的源码包一般都是用</span><span
        style="font-family:'Calibri';font-size:10.5pt;">C</span><span style="font-family:'宋体';font-size:10.5pt;">语言开发的，这也是因为</span><span
        style="font-family:'Calibri';font-size:10.5pt;">C</span><span
        style="font-family:'宋体';font-size:10.5pt;">语言为</span><span
        style="font-family:'Calibri';font-size:10.5pt;">linux</span><span style="font-family:'宋体';font-size:10.5pt;">上最标准的程序语言</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。Linux</span><span
        style="font-family:'宋体';font-size:10.5pt;">上的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">C</span><span
        style="font-family:'宋体';font-size:10.5pt;">语言编译器叫做</span><span style="font-family:'Calibri';font-size:10.5pt;">gcc</span><span
        style="font-family:'宋体';font-size:10.5pt;">，利用它就可以把</span><span style="font-family:'Calibri';font-size:10.5pt;">C</span><span
        style="font-family:'宋体';font-size:10.5pt;">语言变成可执行的二进制文件</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">所以如果你的机器上没有安装</span><span
        style="font-family:'Calibri';font-size:10.5pt;">gcc</span><span style="font-family:'宋体';font-size:10.5pt;">就没有办法去编译源码</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span
        style="font-family:'宋体';font-size:10.5pt;">你可以使用</span><span style="font-family:'Calibri';font-size:10.5pt;"> yum install  -y  gcc </span><span
        style="font-family:'宋体';font-size:10.5pt;">来完成安装</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-indent: 21pt;"><span style="font-family:'宋体';font-size:10.5pt;">安装一个源码包，通常需要三个步骤：</span></p>
<p style="text-indent: 21pt;"><span style="font-family:'Calibri';font-size:10.5pt;">1.  ./config  </span><span
        style="font-family:'宋体';font-size:10.5pt;">在这一步可以定制功能，加上相应的选项即可，具有有什么选项可以通过</span><span
        style="font-family:'Calibri';font-size:10.5pt;">”./config  --help ”</span><span
        style="font-family:'宋体';font-size:10.5pt;">命令来查看</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">在这一步会自动检测你的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">linux</span><span style="font-family:'宋体';font-size:10.5pt;">系统与相关的套件是否有编译该源码包时需要的库，因为一旦缺少某个库就不能完成编译</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">只有检测通过后才会生成一个</span><span
        style="font-family:'Calibri';font-size:10.5pt;">Makefile</span><span style="font-family:'宋体';font-size:10.5pt;">文件</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-indent: 21pt;"><span style="font-family:'Calibri';font-size:10.5pt;">2.  make	  </span><span
        style="font-family:'宋体';font-size:10.5pt;">使用这个命令会根据</span><span
        style="font-family:'Calibri';font-size:10.5pt;">Makefile</span><span style="font-family:'宋体';font-size:10.5pt;">文件中预设的参数进行编译，这一步其实就是</span><span
        style="font-family:'Calibri';font-size:10.5pt;">gcc</span><span
        style="font-family:'宋体';font-size:10.5pt;">在工作了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="margin-left: 21pt;"><span style="font-family:'Calibri';font-size:10.5pt;">3.  make install  </span><span
        style="font-family:'宋体';font-size:10.5pt;">安装步骤，生成相关的软件存放目录和配置文件的过程</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-indent: 21pt;"><span style="font-family:'宋体';font-size:10.5pt;">上面介绍的</span><span
        style="font-family:'Calibri';font-size:10.5pt;">3</span><span style="font-family:'宋体';font-size:10.5pt;">步并不是所有的源码包软件都一样的，笔者以前也曾经遇到过，安装步骤并不是这样，也就是说源码包的安装并非具有一定的标准安装步骤</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">这就需要你拿到源码包解压后，然后进入到目录找相关的帮助文档，通常会以</span><span
        style="font-family:'Calibri';font-size:10.5pt;">INSTALL</span><span style="font-family:'宋体';font-size:10.5pt;">或者</span><span
        style="font-family:'Calibri';font-size:10.5pt;">README</span><span style="font-family:'宋体';font-size:10.5pt;">为文件名</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">所以，你一定要去看一下</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">下面笔者会编译安装一个源码包来帮你更深刻的去理解如何安装源码包</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p><span style="font-family:'Calibri';font-size:10.5pt;">1. </span><span style="font-family:'宋体';font-size:10.5pt;">下载一个源码包</span>
</p>
<p><span style="font-family:'Calibri';font-size:10.5pt;"><img src="11_46.png"></span></p>
<p><span style="font-family:'宋体';font-size:10.5pt;">这里要提一下，建议以后你把所有下载的源码包放到</span><span
        style="font-family:'Calibri';font-size:10.5pt;">/usr/local/src/</span><span
        style="font-family:'宋体';font-size:10.5pt;">目录下，这个并不是必须的，只是一个约定</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">方便你和你的同事将来更好的去运维这台服务器</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。wget</span><span style="font-family:'宋体';font-size:10.5pt;">即为下载的命令，后边跟源码包的下载地址</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">该地址为笔者从网上找的一个</span><span
        style="font-family:'Calibri';font-size:10.5pt;">apache</span><span style="font-family:'宋体';font-size:10.5pt;">的下载地址</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p><span style="font-family:'Calibri';font-size:10.5pt;">2. </span><span style="font-family:'宋体';font-size:10.5pt;">解压源码包</span>
</p>
<p><span style="font-family:'Calibri';font-size:10.5pt;"><img src="11_47.png">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">3. </span><span
        style="font-family:'宋体';font-size:10.5pt;">配置相关的选项，并生成</span><span
        style="font-family:'Calibri';font-size:10.5pt;">Makefile</span></p>
<p style="text-align: "><span style="font-family:'Calibri';font-size:10.5pt;"><img src="11_48.png">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="11_49.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">笔者在这里只定义了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">apache</span><span style="font-family:'宋体';font-size:10.5pt;">的安装目录，其他都是默认</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">回车后，开始执行</span><span
        style="font-family:'Calibri';font-size:10.5pt;">check</span><span
        style="font-family:'宋体';font-size:10.5pt;">操作</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="11_50.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">等</span><span
        style="font-family:'Calibri';font-size:10.5pt;">check</span><span style="font-family:'宋体';font-size:10.5pt;">结束后生成了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">Makefile</span><span style="font-family:'宋体';font-size:10.5pt;">文件</span>
</p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="11_51.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">除了查看有没有生成</span><span
        style="font-family:'Calibri';font-size:10.5pt;">Makefile</span><span style="font-family:'宋体';font-size:10.5pt;">文件来判定有没有完成</span><span
        style="font-family:'Calibri';font-size:10.5pt;">./config </span><span
        style="font-family:'宋体';font-size:10.5pt;">的操作外，还可以通过这个命令</span><span
        style="font-family:'Calibri';font-size:10.5pt;">”echo $?”</span><span
        style="font-family:'宋体';font-size:10.5pt;">来判定，如果是</span><span
        style="font-family:'Calibri';font-size:10.5pt;">0</span><span style="font-family:'宋体';font-size:10.5pt;">，则表示上一步操作成功完成，否则就是没有成功</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="11_52.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">4.  </span><span
        style="font-family:'宋体';font-size:10.5pt;">进行编译</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="11_53.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">这一步操作，就是把源代码编译成二进制的可执行文件，这一步也是最漫长的一步，编译时间的长短取决于源代码的多少和机器配置</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">5.  </span><span
        style="font-family:'宋体';font-size:10.5pt;">安装</span><span
        style="font-family:'Calibri';font-size:10.5pt;">  </span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="11_54.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">在安装前，先确认上一步操作是否成功完成</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="11_55.png"></span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;">make install </span><span
        style="font-family:'宋体';font-size:10.5pt;">会创建相应的目录以及文件</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span><span style="font-family:'宋体';font-size:10.5pt;">当完成安装后，会在</span><span
        style="font-family:'Calibri';font-size:10.5pt;">/usr/local</span><span
        style="font-family:'宋体';font-size:10.5pt;">目录下多了一个</span><span style="font-family:'Calibri';font-size:10.5pt;">apache2</span><span
        style="font-family:'宋体';font-size:10.5pt;">目录，这就是</span><span style="font-family:'Calibri';font-size:10.5pt;">apache</span><span
        style="font-family:'宋体';font-size:10.5pt;">所安装的目录了</span><span
        style="font-family:'Calibri';font-size:10.5pt;">。</span></p>
<p style="text-align: justify;"><span style="font-family:'Calibri';font-size:10.5pt;"><img src="11_56.png">。</span></p>

<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">上一页 <a
        href="10.htm">文档的压缩与打包</a></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;">下一页 <a
        href="12.htm">学习shell脚本之前的基础知识</a></span></p>
<p style="text-align: justify;"><span style="font-family:'宋体';font-size:10.5pt;"><a
        href="index.htm">回到主目录</a>&nbsp;</span></p>

</body>
</html>